import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/routes/tab_moments/model/xindong_dongtai_class.dart';
import 'package:xindong/routes/tab_moments/view/xindong_dongtai_image_view.dart';
import 'package:xindong/routes/tab_moments/view/xindong_dongtai_video_view.dart';
import 'package:xindong/utils/xindong_text_util.dart';

class XinDongDongTaiListViewCellMedia extends StatelessWidget {
  final XinDongDongTaiClass model;
  final BuildContext cellContext;
  final double paddingLeft;

  const XinDongDongTaiListViewCellMedia({Key? key, required this.model, required this.cellContext, required this.paddingLeft}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // model.cover = "https://qianhe.cn-gd.ufileos.com/app_test/moment/android_1634912126_03209188_0.jpg";
    // model.video = "https://qianhe.cn-gd.ufileos.com/app_test/moment/android_1634912108_09513587_1.mp4";
    final hasVideo = !TextUtil.isEmpty(model.video) && !TextUtil.isEmpty(model.cover);
    final hasImage = model.sumbImage.isNotEmpty;
    if (!hasVideo && !hasImage) {
      return const SizedBox();
    }
    return Padding(
      padding: EdgeInsets.only(top: kPaddingValue, left: paddingLeft, right: kPaddingValue),
      child: hasVideo
          ? XinDongDongTaiVideoView(model: model, cellContext: cellContext)
          : hasImage
              ? XinDongDongTaiImageView(
                  dataList: model.sumbImage,
                  viewWidth: screenWidth - paddingLeft - kPaddingValue,
                )
              : null,
    );
  }
}
